<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>微博任务配置</title>
<@fm.header />
<script>

    $(function() {
        $('#isUseful').combobox("select",-1);
    });

function doSearch(){    
    $('#tt').datagrid('load', {
        isUseful: $('#isUseful').combobox('getValue')
    });
}
function add(){
    showMyWindow('新增', '/weiboBrush/add', 600, 400);
}
function edit(){
	var row = $('#tt').datagrid('getSelected');
    if (row){
	    showMyWindow('编辑', '/weiboBrush/'+row.id+'/update', 600, 400);
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}
function del(){
	var row = $('#tt').datagrid('getSelected');
    if (row){
	   showConfirm(market.content.title, market.content.confirm, function(){
		  $.post('/weiboBrush/'+row.id+'/delete', function(data) {
		  	if (data.return_code == '1') {
				top.showMsg(market.content.title, data.return_msg, alert);
				$("#tt").datagrid('reload');
			} else {
				$.messager.alert(market.content.title, data.return_msg);
			}
		  });
	   });
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}

function formatterType(value) {
    if (value == 1) {
        return "启用";
    }
    if (value == 0) {
        return "作废";
    }

}

    function changeStatus(status) {
        var row = $('#tt').datagrid('getSelected');
        var isUseful = row.isUseful;
        if(isUseful==status){
            top.showMsg(market.content.title, "先确认数据状态", alert);
            return;
        }else{
            $.messager.confirm('温馨提醒', '你确定执行吗？', function(r) {
                if (r) {
                    $.get('/weiboBrush/channgeStatus?id=' + row.id + '&isUseful=' + status, function(data) {
                        if (data.return_code == '1') {
                            top.showMsg(market.content.title, data.return_msg, alert);
                            doSearch();
                        } else if (data.return_code == '3') {
                            top.showMsg(market.content.title, data.return_msg, alert);
                        } else {
                            $.messager.alert(market.content.title, data.return_msg);
                        }
                    });
                }
            });
        }
    }


</script>
</head>
<body class="cmp-list-body">
<div id="tb" style="padding:3px">

    <span>状态:</span>
    <select class="easyui-combobox" id="isUseful" panelHeight="auto" style="width:155px" >
        <option value="-1" selected>-选择-</option>
        <option value="1" selected>启用</option>
        <option value="0">废弃</option>
    </select>

    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch();">查询</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add();">新增</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="del();">删除</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit();">修改</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:changeStatus(0)">作废</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:changeStatus(1)">启用</a>
</div>
<table id="tt" class="easyui-datagrid" title="微博配置列表" iconCls="icon-save"
	url="/weiboBrush/list?json" toolbar="#tb" rownumbers="true" idField="ver"
	singleSelect="true" pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
    <thead>
        <tr>
            <th align="center" width="25%" field="code">标识</th>
            <th align="center" width="15%" field="version">版本</th>
            <th align="center" width="25%" field="channelName">渠道</th>
            <th align="center" width="25%" field="isUseful" formatter="formatterType">状态</th>
            <th align="center" width="10%" field="createTime">创建时间</th>
            <th align="center" width="10%" field="modifyTime">更新时间</th>
        </tr>
    </thead>   
</table>
</body>
</html>